<html>
<head>
    <link href="../css/dialog.css" rel="stylesheet">
    <link href="../css/uploadifive.css" rel="stylesheet">
    <script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.js"></script>
    <script src="https://cdn.bootcss.com/jqueryui/1.12.1/jquery-ui.js"></script>
    <script src="https://cdn.bootcss.com/font-awesome/5.10.0-12/js/all.min.js"></script>
    <script type='text/javascript' src='../js/dialog_function.js'></script>
    <script type='text/javascript' src='../js/jquery.uploadifive.js'></script>
    <?php
    include "../class/suggest_needshow.php";
    include '../db/sql.php';
    include '../functions.php';

    ?>
</head>
<body>
<?php
$new_suggest = new \suggest_content\suggest_needshow();
$sug_array["AddTime"] = date("Y-m-d H:i:s");
$sug_array["AddUserId"] = $_COOKIE["user_id"];
$sug_array["Account"] = $_COOKIE["user_id"];
$db->exec("get_Label'SUG'");
$from = $db->query("SELECT TOP(1) label from T_Label WHERE Prefix = 'SUG' ORDER BY ID DESC");
$row = $from->fetch();
$sug_array["SN"] = $row["label"];
$sug_array["AddUserName"] = FindName($db, $sug_array["Account"]);
echo "name".$sug_array["AddUserName"];
$sug_array["AddUserDept"] = FindDept($db, $sug_array["Account"]);
$uid = $sug_array["Account"];
$from_base_user = $db->query("SELECT Mobile from Base_User WHERE Account = '$uid'");
$row_base_user = $from_base_user->fetch();
$sug_array["AddUserMobile"] = $row_base_user["Mobile"];

$sug_array["State"] = "建议发布";
$new_suggest->make_suggest($sug_array);
//$new_suggest->show_form();
?>
<div class='dialog_form'>
    <div class="title_border">
    <div class='form_title'>合理化建议发布</div>
    <a onclick="close_dialog()"><i class="fas fa-times"></i></a>
    </div>
    <div class="dailog_content_border">
    <table>
        <tr>
            <td class="row_name">SN</td>
            <td class="row_content"><input id='SN' class='form_input' readonly='readonly' value='<?php echo $new_suggest->suggest_array['SN'] ?>'></td>
            <td class="row_name">提议日期</td>
            <td class="row_content"><input id='AddTime' class='form_input' readonly='readonly' value='<?php echo $new_suggest->suggest_array['AddTime'] ?>'></td>
        </tr>
        <tr>
            <td class="row_name">员工工号</td>
            <td class="row_content"><input id='Account' class='form_input' readonly='readonly' value='<?php echo $new_suggest->suggest_array['AddUserId'] ?>'></td>
            <td class="row_name">员工姓名</td>
            <td class="row_content"><input id='AddName' class='form_input' readonly='readonly' value='<?php echo $new_suggest->suggest_array['AddUserName'] ?>'></td>
        </tr>
        <tr>
            <td class="row_name">添加人电话</td>
            <td class="row_content"><input id='AddPhone' class='form_input' readonly='readonly' value='<?php echo $new_suggest->suggest_array['AddUserMobile'] ?>'></td>
            <td class="row_name">当前状态</td>
            <td class="row_content"><input id='State' class='form_input' readonly='readonly' value='<?php echo $new_suggest->suggest_array['State'] ?>'></td>
        </tr>
        <tr>
            <td class="row_name">所属部门</td>
            <td class="row_content"><input id='AddUserDept' class='form_input' readonly='readonly' value='<?php echo $new_suggest->suggest_array['AddUserDept'] ?>'></td>
            <td class="row_name">提议名称</td>
            <td class="row_content"><input id='S_Title' class='form_input'></td>
        </tr>
        <tr>
            <td class="row_name">提议类型</td>
            <td class="row_content">
                <select id="S_Type" class="form_input">
                    <?php
                    $from = $db->query("SELECT Cate from T_SuggestType");
                    while($row = $from->fetch()){
                        echo "<option>".$row['Cate']."</option>";
                    }
                    ?>
                </select>
            </td>
            <td class="row_name">重要等级</td>
            <td class="row_content">
                <select id='Suggest_importantLevel' class='form_input'>
                    <?php
                    $from = $db->query("SELECT ItemId from Base_DataItem WHERE ItemCode = 'Suggest_importantLevel' AND EnabledMark = '1'");
                    $row = $from->fetch();
                    $item_id = $row['ItemId'];
                    $from = $db->query("SELECT ItemValue from Base_DataItemDetail WHERE ItemId = '$item_id' AND EnabledMark = '1'");
                    while($row = $from->fetch()){
                        echo "<option>".$row['ItemValue']."</option>";
                    }
                    ?>
                </select>
            </td>
        </tr>
        <tr>
            <td class="row_name">
                建议实施部门
            </td>
            <td class="row_content">
                <select id="SuggestDept" class="form_input" onchange="new_dept_person()">
                    <?php
                    $from = $db->query("SELECT FullName from Base_Department");
                    while($row = $from->fetch()){
                        echo "<option>".$row['FullName']."</option>";
                    }
                    ?>
                </select>
            </td>
            <td class="row_name">
                建议实施人
            </td>
            <td class="row_content">
                <input id="SuggestImpl" class="form_input" onfocus="autocomplete_name()">
            </td>
        </tr>
        <tr>
            <td class="row_name">
                现状描述
            </td>
            <td colspan="3" class="row_content">
                <textarea id="CurrentDesc" name="CurrentDesc" rows="3" class='form_input'></textarea>
            </td>
        </tr>
        <tr>
            <td class="row_name">
                改进措施
            </td>
            <td colspan="3" class="row_content">
                <textarea id="ImproveMethod" name="ImproveMethod" rows="3" class='form_input'></textarea>
            </td>
        </tr>
        <tr>
            <td class="row_name">
                预计效果
            </td>
            <td colspan="3" class="row_content">
                <textarea id="AnticipateResult" name="AnticipateResult" rows="3" class='form_input'></textarea>
            </td>
        </tr>
        <tr>
            <td class="row_name">
                上传文件
            </td>
            <td>
                <input id="uploadify" class='form_input'>
            </td>
            <td colspan="2" class="row_content">
                <div id="queue"></div>
            </td>
        </tr>
    </table>
    <a id="com_btn" onclick="add_sug_complete()">提交合理化建议</a>
    </div>
</div>
</body>
</html>